<?php
session_start();
ob_start();
if (isset($_SESSION["id"]))
    header("Location: http://localhost:82/htnhan-web2/public/index.php" . $users[$index]['id']);
?>
<html>
    <head>
        <title>Nhan</title>
        <link href="public/css/css.css" rel="stylesheet" type="text/css">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript" src="public/jc/jquery-1.2.6.min.js"></script>
        <script type="text/javascript">
            function slideSwitch() {
                var $active = $('#baner IMG.active');
                if ($active.length == 0)
                    $active = $('#baner IMG:last');
                var $next = $active.next().length ? $active.next()
                        : $('#baner IMG:first');
                $active.addClass('last-active');
                $next.css({opacity: 0.0})
                        .addClass('active')
                        .animate({opacity: 1.0}, 1000, function() {
                    $active.removeClass('active last-active');
                });
            }
            $(function() {
                setInterval("slideSwitch()", 3000);
            });
        </script>
    </head>
    <body>
        <div id="wrapper">
            <?php
            require_once './model/works.php';
            $keyword = new Works();
            $keyword->table_name = "works";
            ?>
            <?php
            if (!isset($_GET["page"]))
                $page = 1;
            else
                $page = $_GET["page"];

            $total = $keyword->countWords();
            ?>
            <div id="sum">
                <div id="baner">
                    <img src="data/picture/1.jpg" alt="" class="active"/>
                    <img src="data/picture/2.jpg" alt=""  />
                    <img src="data/picture/3.jpg" alt=""  />
                    <img src="data/picture/5.jpg" alt=""  />
                </div>

                <div id="boder"></div>
                <header>
                    <div class="logo">
                        <h1><b class="Works"></b></h1>
                        <p class="text_td"></p>
                    </div>
                    <div id="boders"></div>
                    <div id="col_left">
                        <h4><?php echo date("m/d/Y"); ?></h4>
                        <p class="main_menu">
                        <h3></h3>
                        <div id="boder_menu"></div>
                        </p>
                        <nav>
                            <ul>
                                <li><a href="index.php">HOME</a></li>
                                <li><a href="#">CONTENT</a></li>
                                <li><a href="#">FORUMS</a></li>
                                <li><a href="#">CONTACT</a></li>
                            </ul>
                        </nav>
                           <?php
        require_once './libraries/utilites/users.php';
        ?>
        <form method="POST">
            Username<input type="text" name="username"><br>
            Password<input type="password"name="password">
            <input type="submit"name="submit">
        </form>
        <?php if (isset($_POST['submit'])): ?>
            <?php
            $username = $_POST['username'];
            $password = $_POST['password'];
            $isOk = FALSE;
            $index = -1;
            for ($i = 0; $i < count($users); $i++) {
                if ((strcmp($users[$i]['username'], $username) == 0) && (strcmp($users[$i][password], $password) == 0)) {
                    $isOk = TRUE;
                    $index = $i;
                }
            }
            if ($isOk) {
                $_SESSION["id"] = $users[$index]["id"];
                header("Location: http://localhost:82/htnhan-web2/index.php");
            } else {
                echo'Dang nhap that bai';
            }
            ?>
                        <?php ob_end_flush(); ?>
        <?php endif; ?>
                    </div>
                    <section>
                        <p class="main_menus">
                        <div id="boder_menus"></div>
                        </p>
                        <div class="fanpage">      
                            
                        </div>
                    </section>
                    <div class="clear"></div>
                    
                </header>
                <div class="clear"></div>
                <div id="boder"></div>
                <footer>
                    <p class="colleft">
                    <table class="o">
                    </table>
                    </p>
                    <p class="colright">
                    <table class="colright">
                        <tr>
                            <td></td><td></td></tr>
                        <tr><td></td><td></td></tr>
                        <tr> <td></td><td></td></tr>
                    </table>
                    </p>
                </footer>
            </div>
        </div>
    </body>
</html>
